package com.sam.nosql;

import android.database.sqlite.SQLiteDatabase;
import android.test.InstrumentationTestCase;
import android.util.Log;

import com.sam.data.UserData;
import com.sam.sqlite.SamSQLiteHelper;
import com.sam.sqlite.UserDao;

import java.util.List;

/**
 * &lt;br&gt;Created
 *
 * @author wangds
 * @see
 */
public class SqliteTest extends InstrumentationTestCase{
    private MainActivity mMainActivity;
    private SQLiteDatabase db;

    @Override
    protected void setUp() throws Exception {
        super.setUp();
        mMainActivity  = launchActivity("com.sam.nosql", MainActivity.class, null);
        SamSQLiteHelper sqLiteHelper = new SamSQLiteHelper(mMainActivity);
        db = sqLiteHelper.getWritableDatabase();
        db.delete(UserData.TABLE_NAME,null,null);
    }

    public void testList(){
        UserDao userDao = new UserDao(db);
        assertTrue(userDao.saveList());
        List<UserData> list = userDao.query();
        assertNotNull(list);
        assertTrue(!list.isEmpty());
        Log.d("dbTest", "list:" + list.size());

    }

}
